package cn.admin.service.impl;

import cn.admin.dao.AdminDaoMapper;
import cn.admin.pojo.Admin;
import cn.admin.pojo.dto.AdminDTO;
import cn.admin.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 毛苏宇
 * User: me
 * Date: 2020/6/24
 * Time: 20:50
 * Description:
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminDaoMapper adminDaoMapper;

    @Override
    public boolean remove(long userId) {
        return adminDaoMapper.delete(userId) > 0 ? true : false;
    }

    @Override
    public AdminDTO find(long userId) {
        return adminDaoMapper.select(userId);
    }

    @Override
    public boolean modify(Admin admin) {
        return adminDaoMapper.update(admin) > 0 ? true : false;
    }

    @Override
    public boolean add(Admin admin) {
        admin.setUpdateTime(System.currentTimeMillis());
        return adminDaoMapper.insert(admin) > 0 ? true : false;
    }


}
